package com.aaa.docter.controller.api;

import com.aaa.docter.service.*;
import com.aaa.docter.vo.CareOrderVo;
import com.aaa.docter.vo.MedicinesVo;
import com.aaa.entity.CheckItem;
import com.aaa.entity.Medicines;
import com.aaa.vo.Result;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;

@RestController
@RequestMapping("/doctor/Medicines")
public class ApiMedicinesController {


@Autowired
private MedicinesService medicinesService; //    药品列表

    @Autowired
    private CheckItemService checkItemService;  //检查项目列表

    @Autowired
    private CareOrderService careOrderService;

//    药品列表查询
//    http://localhost:8871/doctor/Medicines/semed/1/10
    @PostMapping("semed/{currentPage}/{pageSize}")
    public Result<IPage<Medicines>> semd(
            @PathVariable Integer currentPage,
            @PathVariable Integer pageSize,
            @RequestBody MedicinesVo medicinesVo
    ){
        return  medicinesService.findByConditio(currentPage,pageSize,medicinesVo);
    }



//   检查项目列表查询
//    http://localhost:8871/doctor/Medicines/check/1/10
    @PostMapping("check/{currentPage}/{pageSize}")
    public Result<IPage<CheckItem>>check(
            @PathVariable Integer currentPage,
            @PathVariable Integer pageSize,
            @RequestBody MedicinesVo medicinesVo
    ){
        return  checkItemService.findByConditio2(currentPage,pageSize,medicinesVo);
    }


//保存药品,保存检查项目
//    http://localhost:8871/doctor/Medicines/saveCareOrderItem
    @PostMapping("/saveCareOrderItem")
    public Result<String> saveCareOrderItem(@RequestBody CareOrderVo careOrderVo){
        return careOrderService.saveCareOrderItem(careOrderVo);
    }


    //  处方删除
    @PostMapping("/deleteCareOrderItemById/{itemId}/{amount}")
    public Result<String> deleteCareOrderItemById(@PathVariable String itemId, @PathVariable BigDecimal amount){
        return careOrderService.deleteCareOrderItemById(itemId,amount);
    }

//    完成就诊，保存到库
//    http://localhost:8871/doctor/Medicines/wcjz/GH57715016316956672
    @Autowired
    private RegistrationService registrationService;
    @PostMapping("/wcjz/{registrationId}")
    public Result<String> wcjz(@PathVariable String registrationId){
        return registrationService.wcjz(registrationId);
    }

}


